﻿///<reference path="../jquery-1.4.2.min.js />
///<reference path="kooboo.js"/>

kooboo.html = kooboo.html || (function () {
    return {
        hidden: function (name, value) {
            var el = $("<input></input>").attr("type", "hidden");

            if (name != undefined && name != null) {
                el.attr("name", name)
            }

            if (value != undefined && value != null) {
                el.val(value);
            }

            return el;
        },
        textbox: function (name, value) {
            var el = $("<input></input>").attr("type", "text");

            if (name != undefined && name != null) {
                el.attr("name", name)
            }

            if (value != undefined && value != null) {
                el.val(value);
            }

            return el;
        },
        span: function (html) {
            var el = $("<span></span>");

            if (html != undefined && html != null) {
                el.html(html);
            }

            return el;
        },
        tbody: function () {
            var el = $("<tbody></tbody>");
            return el;
        },
        tr: function (html) {
            var el = $("<tr></tr>");
            if (html != undefined && html != null) {
                el.html(html);
            }
            return el;
        },
        td: function (html) {
            var el = $("<td></td>");
            if (html != undefined && html != null) {
                el.html(html);
            }
            return el;
        },
        th: function (html) {
            var el = $("<th></th>");
            if (html != undefined && html != null) {
                el.html(html);
            }
            return el;
        },
        a: function (href, html) {
            var el = $("<a></a>");

            if (href != undefined && href != null) {
                el.attr("href", href);
            }

            if (html != undefined && html != null) {
                el.html(html);
            }


            return el;
        },
        label: function (html) {
            var el = $("<label></label>");
            if (html != undefined && html != null) {
                el.html(html);
            }

            return el;
        },
        select: function () {
            var el = $("<select></select>");

            return el;
        },
        option: function (text, value) {
            var el = $("<option></option>");
            if (text != undefined && text != null) {
                el.html(text);
            }
            if (value != undefined && value != null) {
                el.val(value);
            }

            return el;
        }
    };
})();
